var express = require("express");
//md5
var md5 = require("md5");
// session
var session = require("express-session");
//中间件连接数据库
var MongoStore = require("connect-mongo")(session);

//闪存模块

var app = express();

app.use(express.urlencoded({ extended: false }));
app.use(express.static("public"));

var mongoose = require("mongoose");


// session的配置
app.use(
  session({
    secret: "myuser",
    rolling: true,
    cookie: {
      maxAge: 1000 * 60 * 60,
    },
    store: new MongoStore({
      url: "mongodb://127.0.0.1:27017/Blog",
    }),
  })
);

//数据库
var User = require("./modules/db/user");






//注册
var registerRouter = require("./router/register");
app.use(registerRouter);

//登录
var loginRouter = require("./router/login");
app.use(loginRouter);


var userRouter = require("./router/user");
app.use(userRouter);

var editRouter = require("./router/edit");
app.use(editRouter);







app.listen(5555, function () {
  console.log("服务器启动...");
});
